package com.quanquan.user.repository;

import com.quanquan.user.entity.CommercialDouble;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 功能描述:
 *
 * @ClassName: commercialDoubleRepository
 * @Author: xiaoqianh丶
 * @Date: 2019-07-04 14:44
 * @Version: V1.0
 */
public interface CommercialDoubleRepository extends JpaRepository<CommercialDouble, String>, JpaSpecificationExecutor<CommercialDouble> {
    @Transactional
    @Modifying(clearAutomatically = true)
    @Query(value="update oo_commercial_double set status_remove= 1 where marking_rules_id =?1" ,nativeQuery=true)
    public void removeShip(String markingRulesId);


    /**
     * 根据业态查询
     * @param commercialId
     * @return
     */
    public CommercialDouble findByCommercialId(String commercialId);

    /**
     * 根据业态查询
     * @param commercialId
     * @return
     */
    public CommercialDouble findByCommercialIdAndRemove(String commercialId,Integer num);


    /**
     * 根据规则查询翻倍规则
     * @param markingRulesId
     * @param num
     * @return
     */
    public List<CommercialDouble> findByMarkingRulesIdAndRemove(String markingRulesId, Integer num);
}
